package inventory.daoImplementer;

import dbhandelling.Crude;
import dto.MaterialSpecification;
import inventory.daoInterface.MaterialSpecificationDao;
import inventory.daoInterface.MaterialSpecificationDao;


public class MaterialSpecificationImplementor extends Crude implements MaterialSpecificationDao
{
	
	@Override
	public void add(MaterialSpecification mspecs) throws Exception 
	{
		insert(mspecs);
	}

	@Override
	public void update(MaterialSpecification mspecs) throws Exception 
	{
		super.update("MaterialSpecification", "specCode", mspecs.getSpecCode()+"","mspecs",mspecs.getmSpecs());
		
	}

	@Override
	public void delete(MaterialSpecification mspecs) throws Exception 
	{
		super.delete("MaterialSpecification", "mCode",mspecs.getmCode());
	}

	@Override
	public MaterialSpecification retreive(String conditionField, String ConditionValue) throws Exception 
	{
		MaterialSpecification mspecs=(MaterialSpecification) super.retreive("MaterialSpecification",conditionField, ConditionValue);
		return mspecs;
	}

	@Override
	public MaterialSpecification[] retreiveArray(String conditionField, String conditionValue) throws Exception 
	{
		MaterialSpecification[] materialMasters;
		Object[] obj=super.retreiveArrayOnCondition("MaterialSpecification", conditionField, conditionValue);
		materialMasters=new MaterialSpecification[obj.length];
		
		for(int i=0;i<materialMasters.length;i++)
		{
			materialMasters[i]=(MaterialSpecification) obj[i];
		}
		
		return materialMasters;
	}

	@Override
	public MaterialSpecification[] retreiveAll() throws Exception 
	{
		MaterialSpecification[] materialMasters;
		
		Object[] obj=super.retreiveAll("MaterialSpecification");
		
		materialMasters=new MaterialSpecification[obj.length];
		
		for(int i=0;i<materialMasters.length;i++)
		{
			materialMasters[i]=(MaterialSpecification) obj[i];
		}
		
		return materialMasters;
	}

}
